package com.itheima.blog.article.controller;


import com.itheima.blog.article.dto.CommentDto;
import com.itheima.blog.article.entity.TComment;
import com.itheima.blog.article.service.ITCommentService;
import com.itheima.blog.article.vo.CommentVo;
import com.itheima.common.domain.PageReqDto;
import com.itheima.common.domain.PageResDto;
import com.itheima.common.domain.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 评论表 前端控制器
 * </p>
 *
 * @author lin
 * @since 2023-07-12
 */
@RestController
@RequestMapping("/comment")
@Api(tags ="管理端消息管理相关接口")
@RequiredArgsConstructor
public class TCommentController {

    private final ITCommentService commentService;

    @ApiOperation("分页搜索")
    @GetMapping("/page")
    public PageResDto<CommentVo> findPageList(CommentDto commentDto){
        return commentService.findPageList(commentDto);
    }

    @ApiOperation("评论级联删除")
    @DeleteMapping("/del")
    public R delComment(@RequestParam("ids") List<Long> ids){
        commentService.delComment(ids);
        return R.ok("删除成功");
    }

    @ApiOperation("我的评论展示")
    @GetMapping("/list")
    public PageResDto<TComment> findList(PageReqDto pageReqDto){
        return commentService.findCommentList(pageReqDto);
    }

    @ApiOperation("我的评论展示")
    @GetMapping("/reply")
    public PageResDto<TComment> findReplyList(PageReqDto pageReqDto){
        return commentService.findReplyList(pageReqDto);
    }
}
